import React, { Component } from 'react'
import ACTIONS from '../../../redux/action';
import { connect } from 'react-redux';

class DigitButton extends Component {
    state = { };

    render() {
        return (
            // 点一下更新,点击一下数字将数字更新到输入框
            <button 
                onClick={()=>this.props.add_digit(this.props.digit)}
            >
                { this.props.digit }
                </button>
        );
    }
}

const mapDispatchToProps = {
    add_digit : digit => {
        return {
            type : ACTIONS.ADD_DIGIT,
            digit: digit,
        }
    }
}

export default connect(null,mapDispatchToProps)(DigitButton);